
//执行搜索
function search(page) {
    var base_url ="${pageContext.request.contextPath}/shop?";
    if (shopname != "")
        base_url += shopname;  //http://localhost:8080/shop?name=haidilao&
    if (kw != "")
        base_url += kw;  //http://localhost:8080/shop?name=haidilao&kw=shaokao&
    if (area != "")
        base_url += area;  //http://localhost:8080/shop?name=haidilao&kw=shaokao&area=pingjianglu&
    if (page != "" && page!=undefined) // 测试
        base_url += "page=" + page; //http://localhost:8080/shop?name=haidilao&kw=shaokao&area=pingjianglu&page=2

    console.log("最后要请求的url:"+base_url);


    $.ajax({
        type: "GET",
        datatype: "json",
        url: base_url,
        success: function (result) {
            console.log("查询结果："+result);

            //遍历result中集合数据
            var shopList = result.list;
            console.log("查询商铺集合："+shopList);
            for(var i=0;i<shopList.length;i++){
                var shop = shopList[i];

                //数据渲染 商铺集合数据 + 页码
                var ele ="<li>\n" +
                    "                                    <div class=\"pic\">\n" +
                    "                                        <a href=\"${pageContext.request.contextPath}/shop/${shop.shopId}\">\n" +
                    "                                            <img src=\''' alt=\"\"/>\n" +
                    "                                        </a>\n" +
                    "                                    </div>\n" +
                    "                                    <div class=\"txt\">\n" +
                    "                                        <div class=\"tit\">\n" +
                    "                                            <a href=\"${pageContext.request.contextPath}/shop/${shop.shopId}\">\n" +
                    "                                                    ${shop.shopName}(${shop.branchshopName})\n" +
                    "                                            </a>\n" +
                    "                                            <div class=\"promo-icon\">\n" +
                    "                                            </div>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"comment\">\n" +
                    "                                            <span class=\"sml-rank-stars\"></span>\n" +
                    "                                           <%-- <a href=\"#\"><span>1643</span><span>条评论</span></a>--%>\n" +
                    "                                          <%--  <em class=\"sep\">|</em>--%>\n" +
                    "                                            <a href=\"#\"><span>人均 &nbsp ￥</span>${shop.personConsume}元<span></span></a>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"tag-addr\">\n" +
                    "                                            <a href=\"#\">苏帮菜</a>\n" +
                    "                                            <em class=\"sep\">|</em>\n" +
                    "                                            <a href=\"#\"><span>${shop.shopAddArea}</span></a>\n" +
                    "                                            <span class=\"addr\">${shop.shopAddCity}${shop.shopAddArea}${shop.shopAddStreet}${shop.stopAddDetail}</span>\n" +
                    "                                        </div>\n" +
                    "                                        <div class=\"recommend\">\n" +
                    "                                            <span>标签:</span>\n" +
                    "\n" +
                    "                                                <a href=\"#\">${keyword} | </a>\n" +
                    "\n" +
                    "\n" +
                    "\n" +
                    "                                        </div>\n" +
                    "                                        <span class=\"comment-list\">\n" +
                    "                                        <span>口味</span><span>${shop.flavorScore}</span>\n" +
                    "                                        <span>环境</span><span>${shop.surroundingScore}</span>\n" +
                    "                                        <span>服务</span><span>${shop.serviceScore}</span>\n" +
                    "                                    </span>\n" +
                    "                                    </div>\n" +
                    "                                </li>";


                var shoplistul = $(".shop-list-ul");
                ul.append(ele);
                var li = ul.children("li").eq(i);
                li.find(".pic img").src=shop.mainImage;
            }


        }
    });


};
